import { Observer } from 'mobx-vue'
import { Component, Vue } from 'vue-property-decorator'
import { getStreetList, getCommunityList,getGridList,getComplexList,getDepartmentList} from 'src/utils/axios'
require('./pubArea.scss')
@Observer
@Component({
  props:{
     //是否显示社区
     isShowCommunity:{
      type:Boolean,
      default:true
    },
    //是否显示网格
    isShowGrid:{
      type:Boolean,
      default:true
    },
    //是否显示小区
    isShowComplex:{
      type:Boolean,
      default:false
    },
    //form表单是否并列排列是
    isInline:{
      type:Boolean,
      default:true
    },
    //是否显示查询新增按钮
    isShowBtns:{
      type:Boolean,
      default:true
    },
    //是否显示所属部门
    isShowDepartments:{
      type:Boolean,
      default:false
    }
  }
})
export default class ZtpubArea extends Vue {
    formInline:any = {
      street_code: "",
      community_code: "",
      grid_id: 1,
      complex_id: ""
    }
    streetList:any=[]
    communityList:any =[]
    gridList:any=[]
    complexList:any=[]
    departmentList:any=[]
    cityList:any= [{
            value: 'beijing',
            label: '嘉兴市'
        }
    ]
    mounted() {
        let vm:any = this;
        vm.getStreetList("330411000000");
    }
    //获取街道
    async getStreetList(districtCode){
      let vm:any = this;
      let params = {
        "range": [0, 10000],
        "filter": {
          "district_code": districtCode
         }
      }
      let out:any = await getStreetList(params);
      if(!out.status){
        vm.streetList=out.data.list || [];
      }
    }
    //获取社区
    async getCommunityList(streetCode){
      let vm:any = this;
      let params = {
        "range": [0, 10000],
        "filter": {
          "street_code": streetCode
         }
      }
      let out:any = await getCommunityList(params);
      if(!out.status){
        vm.communityList=out.data.list || [];
      }
    }
    //获取网格
    async getGridList(communityCode){
      let vm:any = this;
      let params = {
        "range": [0, 10000],
        "filter": {
          "community_code": communityCode
         }
      }
      let out:any = await getGridList(params);
      if(!out.status){
        vm.gridList=out.data.list || [];
      }
    }
   //获取小区
   async getComplexList(code){
     let vm:any = this;
     let params = {
       "range": [0, 10000],
       "filter": {
         "community_code": code
        }
      }
      let out:any = await getComplexList(params);
      if(!out.status){
        vm.complexList=out.data.list || [];
      }
   }

   streetChange(val){
      let vm:any=this;
      vm.getCommunityList(val);
   }
   communityChange(val){
      let vm:any=this;
      vm.getComplexList(val);
      //vm.getGridList("111");
   }
}
